package ss9999999999;

public class AnimalsTest {
    public static void main(String[] args) {
        Animals[] animals=new Animals[3];
        animals[0]=new Dog("小米粒",4,"白色");//向上转型
        animals[1]=new Chick("土豆",2,"黄色");
        animals[2]=new Fish("小金",3,"金色");
        Master master=new Master();


        for (int i=0;i< animals.length;i++){
            master.feed(animals[i]);
            animals[i].sayHi();
            if(animals[i] instanceof Swim){
                Swim a=(Swim)animals[i];
                a.swim();
            }
            if(animals[i] instanceof Chick){
                Chick a=(Chick) animals[i];
                a.egg();
            }
            if(animals[i] instanceof Dog){
                Dog a=(Dog) animals[i];
                a.lookHome();
            }
        }
    }

}
